/*      All code produced by the American Heritage School Robotics Team,
 *      The Ninjineers (#2383), for the 2013 FRC Season.
 */

package tk.ninjineers2383.y2013.Components;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.Gyro;

public class Shooter 
{
    final int SHOOTER_DIRECTION = 1;     //-1 to reverse
    final int CLIMBER_DIRECTION = -1;    //-1 to reverse
    final int REVERSE_PIVOT = -1;        //-1 reverse pivot direction
    final int VEX_DIRECTION = 1;
    
    private Victor motor;
    private Victor launch;
    private Victor pivot;
    private Victor vex;
    private Gyro gyro;
    
    public Shooter(int spinners, int actuator, int pivotChan, int gyroChan, int vexChan)
    {
        motor = new Victor(spinners);
        launch = new Victor(actuator);
        pivot = new Victor(pivotChan);
        vex = new Victor(vexChan);
        gyro = new Gyro(gyroChan);
    }
    
    /*
    public double calculateSpeed(double distance, double angle)
    {
        double speed = 0;
        
        //Create 3d array to store predefined angle, distance, and speed combinations for optimal shot. 
        //Round distance and angle to nearest multiple of ten (or something similar) or use bounds to set conditions.
        //Check array for corresponding combination. If no combinatin exists, make sure to display why to the user (out of range/too close/ etc)
        
        return speed;
    }*/
    
    public void spinUp(double speed)
    {
        motor.set(SHOOTER_DIRECTION*speed);
    }
    
    public void stop()
    {
        motor.set(0);
    }
    
    public void pivotUp()
    {
        pivot.set(REVERSE_PIVOT*1);
    }
    
    public void pivotDown()
    {
        pivot.set(REVERSE_PIVOT*(-1));
    }
    
    public void pivotStop()
    {
        pivot.set(0);
    }
    
    public void launchGo(double direction)
    {
        launch.set(direction);
    }
    
    public void launchStop()
    {
        launch.set(0);
    }
    
    public double getAngle()
    {
        return gyro.getAngle();
    }
    
    public void resetGyro()
    {
        gyro.reset();
    }
    
    public void vexIn()
    {
        vex.set(VEX_DIRECTION);
    }
    
    public void vexOut()
    {
        vex.set(-1*VEX_DIRECTION);
    }
    
    public void vexStop()
    {
        vex.set(0);
    }
}
